package org.mnj07.patterns.structural.command;

public class PressSwitch {
  public static void main(String[] args) {
    Light lamp = new Light();
    Command switchUp = new FlipUpCommand(lamp);
    Command switchDown = new FlipDownCommand(lamp);

    Switch s = new Switch();

    boolean showUsage = false;
    if(args.length > 0){
      if(args[0].equalsIgnoreCase("ON")){
        s.storeAndExecute(switchUp);
      }
      else if(args[0].equalsIgnoreCase("OFF")){
        s.storeAndExecute(switchDown);
      }
      else{
        showUsage = true;
      }
    }
    else{
      showUsage = true;
    }

    if(showUsage){
      System.out.println("java PressSwitch \"ON\" or \"OFF\" is required.");
    }
  }
}
